<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .my-link {
            color: #ccc;
        }

        .router-link-active {
            color: #000;
        }
    </style>
</head>

<body>
    <div id="app">
        <router-link class="my-link" to="/user/32214/info/22">用户1-信息</router-link>
        <router-link class="my-link" to="/user/32214/pass">用户1-密码</router-link>
        <router-link class="my-link" to="/user/32214456/info/22">用户2-信息</router-link>
        <router-link class="my-link" to="/user/32214456/pass">用户2-密码</router-link>
        <router-view></router-view>
    </div>
</body>
<script src="js/vue.js"></script>
<script src="js/vue-router.js"></script>
<script>
    // 1.声明路由
    let r1 = new VueRouter({
        routes: [{
            // 顶级路由地址加/
            path: '/user/:id',
            component: {
                template: '<div>当前用户ID :{{$route.params.id}}<router-view></router-view></div>',
            },
            children: [{
                path:'info/:aa',
                component:{
                    template:'<div>用户信息{{$route.params.aa}}</div>'
                }
            },{
                path:'pass',
                component:{
                    template:'<div>用户密码</div>'
                }
            }]
        }]
    });
    // 2.调用路由

    let vm = new Vue({
        el: '#app',
        methods: {

        },
        router: r1,

    })
</script>

</html>